Assignemnt #75 and 73th program
Code
///Name: Derrick Andreasen
///Period: 7
///Program name: 73th Program
///File name: Sev3Prog.java
///Date Finished:12/8/2015
import java.util.Scanner;
import java.util.Random;
public class Sev3Prg
{
public static void main( String[] args )
{
int side1, side2, side3;
double a, b, c;
Scanner keyboard = new Scanner(System.in);
System.out.println( "Enter three integers:" );
System.out.print( "Side 1: " );
side1 = keyboard.nextInt();
System.out.println( "Side 2: " );
side2 = keyboard.nextInt();
if(side1 > side2)
{
while( side1 > side2 );
{
System.out.println( side2 + " is smaller than " + side1 + ". Try again." );
System.out.println( "Side 2: " );
side2 = keyboard.nextInt();
}
}
System.out.print( "Side 3: " );
side3 = keyboard.nextInt();
if(side2 > side3)
{
while( side2 < side3 );
{
System.out.println( side3 + "is smaller than " + side2 + ". Try again." );
System.out.println( "Side 3: " );
side3 = keyboard.nextInt();
}
}
a = Math.sqrt(side1);
b = Math.sqrt(side2);
c = a + b;
if( c == side3 )
{
System.out.println( "Your three sides " + side1+ " " + side2 + " " + side3 );
System.out.println( "These sides make a right triangle!" );
}
else if( c != side3 )
{
System.out.println( "Your three sides " + side1+ " " + side2 + " " + side3 );
System.out.println( "These sides do not make a right triangle. Sorry." );
}
}
}
Picture of the output